package com.le.tester.book.effectivejava3rdchinese.secondReading.l42;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * createTime：2024-09-25 9:14
 * description：lambda表达式优于匿名类
 */
public class Demo {
    private final List<String> words = new ArrayList<>();

    public void f() {
        //匿名类
        Collections.sort(words, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return Integer.compare(o1.length(), o2.length());
            }
        });
    }
}
